package com.codedancer.campus.enums;

import cn.hutool.core.util.ObjectUtil;
import com.codedancer.campus.common.enums.CodeDbEnum;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @Author codeworld 头条新闻类型
 **/
public enum HeadlineNewsType implements CodeDbEnum {

    LOCAL_NEWS(1, "本地新闻"),
    OTHER_NEWS(2, "其他新闻");

    /**
     * 对应的值
     */
    @JsonValue
    private final Integer value;

    /**
     * 对应的名称
     */
    private final String name;

    HeadlineNewsType(Integer value, String name) {
        this.value = value;
        this.name = name;
    }

    public static HeadlineNewsType fromValue(Integer value) {
        for (HeadlineNewsType headlineNewsType : HeadlineNewsType.values()) {
            if (ObjectUtil.equal(headlineNewsType.getValue(), value)) {
                return headlineNewsType;
            }
        }
        return null;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    public String getName() {
        return name;
    }
}
